package creational.singleton.lazyman;

import creational.singleton.Singleton;

/**
 * 懒汉式单例2,线程安全,但是锁范围太大,性能欠佳
 *
 * @author binbin
 * @since 2022/10/4 14:26
 */
public class LazyManSingleton2 implements Singleton {

    private static volatile LazyManSingleton2 instance;

    private static Object lock;

    private LazyManSingleton2() {
    }

    public static synchronized LazyManSingleton2 getInstance() {
        if (instance == null) {
            instance = new LazyManSingleton2();
        }
        return instance;
    }
}
